package com.longge;

public class CountAsterisks {

    public int countAsterisks(String s) {

        char[] chars = s.toCharArray();
        int count = 0, ans = 0;
        boolean flag = true;
        for (char aChar : chars) {
            if (flag && aChar == '*') {
                ans++;
            }else if (aChar=='|'&&count==0){
                count++;
                flag = false;
            }else if (aChar=='|'&&count==1){
                count--;
                flag = true;
            }
        }
        return ans;
    }
}
